/*-- Energiegewehr --*/

#strict

#include WEPN

// Anzeige in der Hand
public func HandSize() { return(950); }
public func HandX()    { return(5000); }
public func HandY()    { return(2000); }
public func BarrelXOffset(){return(-2000);}
public func BarrelYOffset(){return(-2000);}

public func FMData1(int data)
{
  if(data == FM_Name)      return("Taser");
  if(data == FM_AmmoID)    return(ENAM);
  if(data == FM_AmmoLoad)  return(1);

  if(data == FM_Reload)    return(36);
  if(data == FM_Recharge)  return(8);

  if(data == FM_AmmoUsage) return(1);
  if(data == FM_AmmoRate)  return(1);
  if(data == FM_Auto)      return(false);

  if(data == FM_Damage)    return(0);

  return(Default(data));
}

public func Fire1()    // Laserschuss
{ 
  var user = GetUser();
  var x,y; user->WeaponEnd(x,y);
  var angle = user->AimAngle(8) + RandomX(-2,+1);
  var laser = CreateObject(LASR,x,y,GetController(user));
  laser->SetClrModulation(RGB(252,255,184));
  laser->Set(angle,7,60,7,this());
  // Effekte
  MuzzleFlash(40,user,x,y,angle,RGBa(50,100,255,0));

  // Sound
  Sound("melee_spark",0,laser);
}


public func LaserStrike(object pTarget) {   // Laser trifft
  if(GetAction(pTarget) S= "Dead") return(1);
  Sound("Kurz", 0, pTarget, 200);
  ObjectSetAction(pTarget, "Dead");
  Schedule(Format("ObjectSetAction(Object(%d), \"FlatUp\", 0, 0, 1)", ObjectNumber(pTarget)), 110, 0, pTarget);
  return(1);
}

public func OnReload()
{
  Sound("EnergyRifleLoad");
}
